package com.macaline.concurrent;

import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;

class Stu implements Callable{

    @Override
    public Object call() throws Exception {
        System.out.println(Thread.currentThread().getName() + "名同学离开教室");

        return 1;
    }
}

public class CountDownLatchDemo {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);



        for (int i = 0; i < 6; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName() + "名同学离开教室");
                countDownLatch.countDown();
            }, i + 1 + "").start();
        }
        countDownLatch.await();
        System.out.println("班长进行关门");
    }
}
